package com.nbufe.combination.demo1;

import java.util.ArrayList;

public class Folder extends AbstractFile {

    private ArrayList<AbstractFile> fileList;

    private String name;

    public Folder(String name) {
        this.name = name;
        fileList = new ArrayList<>();
    }

    @Override
    public void add(AbstractFile abstractFile) {
        fileList.add(abstractFile);
    }

    @Override
    public void remove(AbstractFile abstractFile) {
        fileList.remove(abstractFile);
    }

    @Override
    public AbstractFile getChild(int i) {
        return fileList.get(i);
    }

    @Override
    public void killVirus() {
        System.out.println("对文件夹进行杀毒");
        for (AbstractFile abstractFile : fileList) {
            abstractFile.killVirus();
        }
    }
}
